#include "messages.h"
#include "ui_messages.h"
#include <QDebug>
#include <time.h>

Messages::Messages(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Messages)
{
    ui->setupUi(this);

    //    ven[0].rec_v->c_r->id

}

Messages::~Messages()
{
    delete ui;
}

void Messages::on_pushButton_clicked()
{
    if(rec_m.count()==0)
    {
        ui->label->setText("空");
        return;
    }
    //        QString messagetext = "车辆数据：车牌："+QString().number(rec_m[0].c_r->id);
    //        ui->label->setText(messagetext);
    QString messagetext = "";
    for (int i=0; i<rec_m.count(); i++)
    {
        messagetext   = messagetext + "\n 车辆数据：车牌："+QString().number(rec_m[i].c_r->id)+"缴费："+QString().number(rec_m[i].moneyP);
        struct tm* ti;
//        time(&rec_m[i].inP);
        ti = localtime(&rec_m[i].inP);
        struct tm* tj;
//        time(&rec_m[i].outP);
        tj = localtime(&rec_m[i].outP);
        messagetext = messagetext + "入场时间："+QString().number(ti->tm_year+1900)+"/"+QString().number(ti->tm_mon+1)+"/"+QString().number(ti->tm_mday)+" "+QString().number(ti->tm_hour)+":"+QString().number(ti->tm_min)+":"+QString().number(ti->tm_sec);
        messagetext = messagetext + "出场时间："+QString().number(tj->tm_year+1900)+"/"+QString().number(tj->tm_mon+1)+"/"+QString().number(tj->tm_mday)+" "+QString().number(tj->tm_hour)+":"+QString().number(tj->tm_min)+":"+QString().number(tj->tm_sec);
//        if(rec_m[i].isAd)
//        {messagetext = messagetext + "进入车位过了";}
//        else
//        {messagetext = messagetext + "没有进入过车位";}
    }
    messagetext = messagetext + "\n 点击显示刷新";
    ui->label->setText(messagetext);
}

void Messages::on_pushButton_2_clicked()//关闭细节窗口
{
    close();
}
